WIDTH = 500
HEIGHT = 500
STEP = 10
CUR = 10
unit = 100
k = [
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0],
]

class MyRect:
    def __init__(self, x, y, w, h, clr):
        self.x = x
        self.y = y
        self.clr = clr
    def Draw(self):
        rc = Rect((self.x - unit // 2, self.y - unit // 2), (unit, unit))
        screen.draw.filled_rect(rc, self.clr)

rc_li = []

def reset():
    global CUR
    global STEP
    global k
    x = 0
    y = 0
    count = 25
    k[x][y] = CUR
    CUR += STEP

    count -= 1
    while count > 0:
        while x + 1 < 5 and k[x + 1][y] == 0:
            x += 1
            k[x][y] = CUR
            CUR += STEP
            count -= 1

        while y - 1 >= 0 and k[x][y - 1] == 0:
            y -= 1
            k[x][y] = CUR
            CUR += STEP
            count -= 1

        while x - 1 >= 0 and k[x - 1][y] == 0:
            x -= 1
            k[x][y] = CUR
            CUR += STEP
            count -= 1

        while y + 1 < 5 and k[x][y + 1] == 0:
            y += 1
            k[x][y] = CUR
            CUR += STEP
            count -= 1

    for xx in range(0, 5):
        for yy in range(0, 5):
            ra = MyRect(xx * unit + unit // 2, yy * unit + unit // 2, unit, unit, (k[xx][yy], 0, 0))
            rc_li.append(ra)

reset()

def draw():
    for rc in rc_li:
        rc.Draw()